#ifndef YafridngRendererI_H
#define YafridngRendererI_H

#include <Ice/Ice.h>
#include <FileStoreI.h>
#include <FileManager.h>
#include <Yafridng.h>

using namespace std;
using namespace Yafridng;

class AMI_YafridngRenderManager_updateZoneI : public AMI_YafridngRenderManager_updateZone
{
 public:
  void ice_response()
  {
    //Blank Callback
  }
  void ice_exception(const Ice::Exception& ex)
  {
    cout << "Excepcion en el callback: " << ex << endl;
  }
};

#define SLEEP -2
#define END -1

class YafridngRendererI : public YafridngRenderer
{
 public:
  YafridngRendererI(const string& category,
		    const ::Ice::Int renderEngine,
		    const string& scene, 
		    Ice::CommunicatorPtr com);

  virtual void obtainFile(const ::Yafridng::Pieces& piecesList,
			  ::Ice::Int piece,
			  ::Ice::Int fileSize,
			  const ::Yafridng::FilePrx& f,
			  const ::Yafridng::P2PBrokerPrx& broker,
			  const ::Ice::Current&);

  virtual void render(const ::Yafridng::TZones& zones,
		      const ::Yafridng::YafridngRenderManagerPrx& manager,
		      const ::Ice::Current&);

  virtual void flush(const ::Ice::Current&);

 private:
  void createEmptyFile(string name, int size);
  int getFileSize(string file);
  Ice::ObjectAdapterPtr _resultAdapter;
  int _renderEngine;
  string _scene;
  string _category;
};
#endif
